.class public Lrexsee/communication/RexseeSMSSender;
.super Ljava/lang/Object;
.source "RexseeSMSSender.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field public static final ACTION_SMS_DELIVERED:Ljava/lang/String; = "DELIVERED_SMS_ACTION"

.field public static final ACTION_SMS_SENT:Ljava/lang/String; = "SENT_SMS_ACTION"

.field public static final EVENT_ONSMSDELIVERED:Ljava/lang/String; = "onSmsDelivered"

.field public static final EVENT_ONSMSSENT:Ljava/lang/String; = "onSmsSent"

.field public static final EXTRA_SMS_ID:Ljava/lang/String; = "smsID"

.field public static final EXTRA_SMS_PART:Ljava/lang/String; = "smsPart"

.field public static final EXTRA_SMS_PART_TOTAL:Ljava/lang/String; = "smsPartTotal"

.field private static final INTERFACE_NAME:Ljava/lang/String; = "SMSSender"


# instance fields
.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private final mContext:Landroid/content/Context;

.field private final mDeliveredReceiver:Landroid/content/BroadcastReceiver;

.field private mId:Ljava/lang/String;

.field private final mSentReceiver:Landroid/content/BroadcastReceiver;

.field private mSentSize:I

.field private mTotalSize:I


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 2
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    const/4 v1, 0x0

    .line 82
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 44
    const-string v0, ""

    iput-object v0, p0, Lrexsee/communication/RexseeSMSSender;->mId:Ljava/lang/String;

    .line 45
    iput v1, p0, Lrexsee/communication/RexseeSMSSender;->mTotalSize:I

    .line 46
    iput v1, p0, Lrexsee/communication/RexseeSMSSender;->mSentSize:I

    .line 64
    new-instance v0, Lrexsee/communication/RexseeSMSSender$1;

    invoke-direct {v0, p0}, Lrexsee/communication/RexseeSMSSender$1;-><init>(Lrexsee/communication/RexseeSMSSender;)V

    iput-object v0, p0, Lrexsee/communication/RexseeSMSSender;->mSentReceiver:Landroid/content/BroadcastReceiver;

    .line 74
    new-instance v0, Lrexsee/communication/RexseeSMSSender$2;

    invoke-direct {v0, p0}, Lrexsee/communication/RexseeSMSSender$2;-><init>(Lrexsee/communication/RexseeSMSSender;)V

    iput-object v0, p0, Lrexsee/communication/RexseeSMSSender;->mDeliveredReceiver:Landroid/content/BroadcastReceiver;

    .line 83
    iput-object p1, p0, Lrexsee/communication/RexseeSMSSender;->mBrowser:Lrexsee/core/browser/Browser;

    .line 84
    invoke-virtual {p1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lrexsee/communication/RexseeSMSSender;->mContext:Landroid/content/Context;

    .line 85
    iget-object v0, p1, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onSmsSent"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 86
    iget-object v0, p1, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onSmsDelivered"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 87
    return-void
.end method

.method static synthetic access$0(Lrexsee/communication/RexseeSMSSender;)I
    .locals 1

    .prologue
    .line 46
    iget v0, p0, Lrexsee/communication/RexseeSMSSender;->mSentSize:I

    return v0
.end method

.method static synthetic access$1(Lrexsee/communication/RexseeSMSSender;I)V
    .locals 0

    .prologue
    .line 46
    iput p1, p0, Lrexsee/communication/RexseeSMSSender;->mSentSize:I

    return-void
.end method

.method static synthetic access$2(Lrexsee/communication/RexseeSMSSender;)I
    .locals 1

    .prologue
    .line 45
    iget v0, p0, Lrexsee/communication/RexseeSMSSender;->mTotalSize:I

    return v0
.end method

.method static synthetic access$3(Lrexsee/communication/RexseeSMSSender;)Lrexsee/core/browser/Browser;
    .locals 1

    .prologue
    .line 42
    iget-object v0, p0, Lrexsee/communication/RexseeSMSSender;->mBrowser:Lrexsee/core/browser/Browser;

    return-object v0
.end method

.method static synthetic access$4(Lrexsee/communication/RexseeSMSSender;)Ljava/lang/String;
    .locals 1

    .prologue
    .line 44
    iget-object v0, p0, Lrexsee/communication/RexseeSMSSender;->mId:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$5(Lrexsee/communication/RexseeSMSSender;I)Ljava/lang/String;
    .locals 1

    .prologue
    .line 48
    invoke-direct {p0, p1}, Lrexsee/communication/RexseeSMSSender;->getResultString(I)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method private getResultString(I)Ljava/lang/String;
    .locals 2
    .param p1, "resultCode"    # I

    .prologue
    const-string v1, "OK"

    .line 49
    packed-switch p1, :pswitch_data_0

    .line 61
    :pswitch_0
    const-string v0, "OK"

    move-object v0, v1

    :goto_0
    return-object v0

    .line 51
    :pswitch_1
    const-string v0, "OK"

    move-object v0, v1

    goto :goto_0

    .line 53
    :pswitch_2
    const-string v0, "RESULT_ERROR_GENERIC_FAILURE"

    goto :goto_0

    .line 55
    :pswitch_3
    const-string v0, "RESULT_ERROR_NO_SERVICE"

    goto :goto_0

    .line 57
    :pswitch_4
    const-string v0, "RESULT_ERROR_NULL_PDU"

    goto :goto_0

    .line 59
    :pswitch_5
    const-string v0, "RESULT_ERROR_RADIO_OFF"

    goto :goto_0

    .line 49
    nop

    :pswitch_data_0
    .packed-switch -0x1
        :pswitch_1
        :pswitch_0
        :pswitch_2
        :pswitch_5
        :pswitch_4
        :pswitch_3
    .end packed-switch
.end method


# virtual methods
.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 24
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 20
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "SMSSender"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 28
    new-instance v0, Lrexsee/communication/RexseeSMSSender;

    invoke-direct {v0, p1}, Lrexsee/communication/RexseeSMSSender;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public send(Ljava/lang/String;Ljava/lang/String;)V
    .locals 1
    .param p1, "phoneNumber"    # Ljava/lang/String;
    .param p2, "message"    # Ljava/lang/String;

    .prologue
    .line 91
    const/4 v0, 0x0

    invoke-virtual {p0, v0, p1, p2}, Lrexsee/communication/RexseeSMSSender;->send(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 92
    return-void
.end method

.method public send(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    .locals 11
    .param p1, "id"    # Ljava/lang/String;
    .param p2, "phoneNumber"    # Ljava/lang/String;
    .param p3, "message"    # Ljava/lang/String;

    .prologue
    .line 95
    invoke-static {}, Landroid/telephony/SmsManager;->getDefault()Landroid/telephony/SmsManager;

    move-result-object v0

    .line 96
    .local v0, "sms":Landroid/telephony/SmsManager;
    invoke-virtual {v0, p3}, Landroid/telephony/SmsManager;->divideMessage(Ljava/lang/String;)Ljava/util/ArrayList;

    move-result-object v3

    .line 97
    .local v3, "msgs":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/lang/String;>;"
    invoke-virtual {v3}, Ljava/util/ArrayList;->size()I

    move-result v1

    iput v1, p0, Lrexsee/communication/RexseeSMSSender;->mTotalSize:I

    .line 98
    const/4 v1, 0x0

    iput v1, p0, Lrexsee/communication/RexseeSMSSender;->mSentSize:I

    .line 99
    if-eqz p1, :cond_1

    invoke-virtual {p1}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v1

    const-string v2, ""

    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-nez v1, :cond_1

    move-object v1, p1

    :goto_0
    iput-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mId:Ljava/lang/String;

    .line 102
    :try_start_0
    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mContext:Landroid/content/Context;

    iget-object v2, p0, Lrexsee/communication/RexseeSMSSender;->mSentReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v1, v2}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V

    .line 103
    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mContext:Landroid/content/Context;

    iget-object v2, p0, Lrexsee/communication/RexseeSMSSender;->mDeliveredReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v1, v2}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 107
    :goto_1
    const/4 v4, 0x0

    .line 108
    .local v4, "sentIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    const/4 v5, 0x0

    .line 109
    .local v5, "deliveryIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mId:Ljava/lang/String;

    if-eqz v1, :cond_0

    .line 110
    new-instance v4, Ljava/util/ArrayList;

    .end local v4    # "sentIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    invoke-direct {v4}, Ljava/util/ArrayList;-><init>()V

    .line 111
    .restart local v4    # "sentIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    new-instance v5, Ljava/util/ArrayList;

    .end local v5    # "deliveryIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    invoke-direct {v5}, Ljava/util/ArrayList;-><init>()V

    .line 112
    .restart local v5    # "deliveryIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mContext:Landroid/content/Context;

    const/4 v2, 0x0

    new-instance v6, Landroid/content/Intent;

    const-string v7, "DELIVERED_SMS_ACTION"

    invoke-direct {v6, v7}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    const/4 v7, 0x0

    invoke-static {v1, v2, v6, v7}, Landroid/app/PendingIntent;->getBroadcast(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v6

    .line 113
    .local v6, "deliverPI":Landroid/app/PendingIntent;
    const/4 v7, 0x0

    .local v7, "i":I
    :goto_2
    iget v1, p0, Lrexsee/communication/RexseeSMSSender;->mTotalSize:I

    if-lt v7, v1, :cond_2

    .line 119
    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mContext:Landroid/content/Context;

    iget-object v2, p0, Lrexsee/communication/RexseeSMSSender;->mDeliveredReceiver:Landroid/content/BroadcastReceiver;

    new-instance v6, Landroid/content/IntentFilter;

    .end local v6    # "deliverPI":Landroid/app/PendingIntent;
    const-string v7, "DELIVERED_SMS_ACTION"

    .end local v7    # "i":I
    invoke-direct {v6, v7}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, v2, v6}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 121
    :cond_0
    const/4 v2, 0x0

    move-object v1, p2

    invoke-virtual/range {v0 .. v5}, Landroid/telephony/SmsManager;->sendMultipartTextMessage(Ljava/lang/String;Ljava/lang/String;Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;)V

    .line 123
    return-void

    .line 99
    .end local v4    # "sentIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    .end local v5    # "deliveryIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    :cond_1
    const/4 v1, 0x0

    goto :goto_0

    .line 114
    .restart local v4    # "sentIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    .restart local v5    # "deliveryIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    .restart local v6    # "deliverPI":Landroid/app/PendingIntent;
    .restart local v7    # "i":I
    :cond_2
    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mContext:Landroid/content/Context;

    const/4 v2, 0x0

    new-instance v8, Landroid/content/Intent;

    new-instance v9, Ljava/lang/StringBuilder;

    const-string v10, "SENT_SMS_ACTION_"

    invoke-direct {v9, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v9, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v8, v9}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    const/4 v9, 0x0

    invoke-static {v1, v2, v8, v9}, Landroid/app/PendingIntent;->getBroadcast(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v8

    .line 115
    .local v8, "sentPI":Landroid/app/PendingIntent;
    invoke-virtual {v4, v8}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 116
    iget-object v1, p0, Lrexsee/communication/RexseeSMSSender;->mContext:Landroid/content/Context;

    iget-object v2, p0, Lrexsee/communication/RexseeSMSSender;->mSentReceiver:Landroid/content/BroadcastReceiver;

    new-instance v8, Landroid/content/IntentFilter;

    .end local v8    # "sentPI":Landroid/app/PendingIntent;
    new-instance v9, Ljava/lang/StringBuilder;

    const-string v10, "SENT_SMS_ACTION_"

    invoke-direct {v9, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v9, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v8, v9}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, v2, v8}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 117
    invoke-virtual {v5, v6}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 113
    add-int/lit8 v7, v7, 0x1

    goto :goto_2

    .line 104
    .end local v4    # "sentIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    .end local v5    # "deliveryIntents":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/app/PendingIntent;>;"
    .end local v6    # "deliverPI":Landroid/app/PendingIntent;
    .end local v7    # "i":I
    :catch_0
    move-exception v1

    goto :goto_1
.end method
